import React, { useEffect } from 'react'
import { Link, Outlet, useNavigate } from 'react-router-dom'

export default function IndexPage() {


 const navi = useNavigate()

 useEffect(()=>{  
  setInterval(() => {
    navi("/"); 
  }, 5000);

},[])


  return (
    <>


  
  <ul>
    <li> <Link to={"/"}>index page</Link> </li>
    <li> <Link to={"/home"}>home</Link> </li>
    <li> <Link to={"/login"}>login</Link> </li>
    <li> <Link to={"/navigate"}>navigate</Link> </li>
    {/* /navigate/admin/update[id] */}
    <li> <Link to={"/navigate/admin/update[id]"}>AdminUserUpdate</Link> </li>
  </ul>

  <hr />
      <Outlet/>

      <hr />

      <button onClick={()=>{

        const path = "/navigate/admin/update[id]"
        const path1 = "/role/update[roleId]"
        const path2 = "/role/update"

        const reg = new RegExp("\\[([^\\]]+)\\]");

        console.log(reg.exec(path))
        console.log(reg.exec(path1))
        console.log(reg.exec(path2))


      }}>测试正则匹配</button>
    </>
  )
}
